<?php
class User_model extends CI_Model {

    //var $date    = '';

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function get_user($user_id)
    {
        //$this->db->get('')
    }
    function try_login($username,$password)
    {
        $pass = sha1($password);
        
        $result = $this->db->select(array('user_id','username','name','surname'))->where(array('username' => $username , 'password' => $pass))->get('users');
        if( $result->num_rows() > 0 )
        {
            return $result->result();   
        }
        else
        {
            return false;
        }        
    }
    function register_user($username,$password,$name,$surname,$email)
    {
        $data = array(
           'username'   =>  $username ,
           'password'   =>  sha1($password) ,
           'email'      =>  $email,
           'name'       =>  $name,
           'surname'    =>  $surname
        );
        
        if($this->db->insert('users', $data))
        {
            return true;
        }
        else
        {
            die($this->db->_error_message());
        } 
    }
}
?>